<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>添加图书</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body{
font-size:12px;
}
table{

	font-size:13px;
}
div{
width:500px;
height:500px;
}
select{
width:156px;
}
.bt{
width:80px;
margin-left:60px;
margin-top:30px;
}
td{
height:45px;
text-align:left;
padding-left:50px;
}
.image{
width:156px;
}
</style>
  </head>
  
  <body>
  <div>
   <form action="jsp/book/bookadd_list" method="post" enctype="multipart/form-data">
   <table>
   <tr>
   <td>图书名称：</td>
   <td><input type="text" id="bname" name="bname">
<a id="show"></a></td>
   </tr>
    <tr>
   <td>图书类目：</td>
   <td><select name="btype">
    <option value="0">小说</option>
    <option value="1">文学</option>
    <option value="2">计算机</option>
    <option value="3">金融</option>
    <option value="4">历史</option>
    <option value="5">心理</option>
    </select></td>
   </tr>
   <tr>
   <td>图书作者：</td>
   <td><input type="text" name="bauthor"></td>
   </tr>
   <tr>
   <td>出版社：</td>
   <td><input type="text" name="bpress"></td>
   </tr>
   <tr>
   <td>购买数量：</td>
   <td><input type="text" id="bnum" name="bnum">
    <a id="show1"></a></td>
   </tr>
   <tr>
   <td>单价：</td>
   <td><input type="text" id="bprice" name="bprice">
   <a id="show2"></a></td>
   </tr>
   <tr>
   <td>图书封面：</td>
     
     <td><input type="file" name="b_image" class="image"></td>

   </tr>
   </table>
        <input  type='submit' value='提交' class="bt" id="btn"/>
  <input  type='button' value='重置' class="bt" onclick="res()"/>
   </form>
   </div>
  </body>
    <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
  <script type="text/javascript">
    $(document).ready(function(){
   $("#btn").attr("disabled", true);
  $("#bname").blur(function(){
  	if($(this).val()==""||$.trim($(this).val()).length==0){
  	$('#show').text("请输入账号").css("color","red");
  		  $("#btn").attr("disabled", true);	
  	}else{	
  	  	var sh="OK";
  	  	$('#show').text("OK").css("color","green");
  	  	if($('#show1').text()==sh&&$('#show2').text()==sh)
	$("#btn").attr("disabled", false);
  	
  	
  	
  	}
  });
  
    $("#bnum").blur(function(){
  var t=/^[0-9]*$/;
  if($(this).val()==""&&$.trim($(this).val()).length==0){
  	$('#show1').text("请输入数量").css("color","red");
	 	$("#btn").attr("disabled", true);
  }else if(!t.test($(this).val())){
	$('#show1').text("请输入整数").css("color","red");
	 	$("#btn").attr("disabled", true);
  	}else if($(this).val()=="0"){
  	$('#show1').text("不能为0").css("color","red");
  	$("#btn").attr("disabled", true);
  	}else{
  	var sh="OK";
  	$('#show1').text("OK").css("color","green");
if($('#show2').text()==sh&&$('#show').text()==sh)
	$("#btn").attr("disabled", false);
  	}	
  });
  
   $("#bprice").blur(function(){
  var t=/^[0-9]+(.[0-9]{1,2})?$/;
  if($(this).val()==""&&$.trim($(this).val()).length==0){
  	$('#show2').text("请输入单价").css("color","red");
	 	$("#btn").attr("disabled", true);
 	 }else if(!t.test($(this).val())){
	$('#show2').text("请输入最多小数为2位的实数").css("color","red");
	 	$("#btn").attr("disabled", true);
  	}else if($(this).val()=="0"){
  	$('#show2').text("不能为0").css("color","red");
  	$("#btn").attr("disabled", true);
  	}else{
  	var sh="OK";
  
  	$('#show2').text("OK").css("color","green");
if($('#show1').text()==sh&&$('#show').text()==sh)
	$("#btn").attr("disabled", false);
  	}
  });
    });
    	function res(){
  	$("#btn").attr("disabled", true);
$('table input').val("");
	$('#show').text("");
	$('#show2').text("");
		$('#show1').text("");
  	}
  </script>
</html>
